home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include "dict.h"
- #include "cgilib.h"
-
- void main(int argc, char *argv[])
- {
- /* Variables for the data. */
-
- char *data = (char *) 0;
- Dictionary dataDict;
- const char *choice , *theUrl;
-
- /*
- * Create a dictionary to hold the data.
- */
-
- dataDict = dict_alloc();
-
- /*
- * Read the data, passing the string data by reference.
- * readData() will alloc space for it. readData() will also determine
- * the request type.
- */
-
- readData(&data);
-
- /*
- * Call parseData() to break the data into key-value pairs.
- * This function will print the pairs.
- */
- if(data) parseData(data,dataDict);
-
- choice = (const char *)dict_valueForKey(dataDict,"choice");
-
- if(choice && !strcmp(choice,"Yahoo"))
- {
- theUrl = "http://www.yahoo.com";
- }
- else
- {
- theUrl = "http://www.webcrawler.com";
- }
-
- /*Output a complete url*/
-
- printf("Location: %s\n\n",theUrl);
-
-
- if(data) free(data);
-
- dict_free(dataDict);
-
- /* End the program */
- exit(0);
- }
-
-